<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      th:replace="header" lang="en">
<div th:fragment="content">

    <div class="row">


        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">
                    <div class="col-sm-8 col-lg-4">
                        <div class="card bg-primary">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">应填报学生人数</p>
                                    <p class="h3 text-white m-b-0" th:text="${taskDetail.getTotal()}+' 人'">0人</p>
                                </div>
                                <div class="pull-left"> <span class="img-avatar img-avatar-48 bg-translucent"><i class="mdi mdi-account fa-1-5x"></i></span> </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-8 col-lg-4">
                        <div class="card bg-success">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">已填报学生人数</p>
                                    <p class="h3 text-white m-b-0" th:text="${reportTotal}">0人</p>
                                </div>
                                <div class="pull-left"> <span class="img-avatar img-avatar-48 bg-translucent"><i class="mdi mdi-check fa-1-5x"></i></span> </div>
                            </div>
                        </div>
                    </div>

                    <div class="col-sm-8 col-lg-4">
                        <div class="card bg-danger">
                            <div class="card-body clearfix">
                                <div class="pull-right">
                                    <p class="h6 text-white m-t-0">未填报学生人数</p>
                                    <p class="h3 text-white m-b-0" th:text="${taskDetail.getTotal()-reportTotal}+' 人'">0人</p>
                                </div>
                                <div class="pull-left"> <span class="img-avatar img-avatar-48 bg-translucent"><i class="mdi mdi-window-close fa-1-5x"></i></span> </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card-actions">
                    <a class="btn btn-success" th:href="'/Download/Excel/'+${taskId}">导出Excel</a>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>姓名</th>
                                <th>学号</th>
                                <th>学院</th>
                                <th>班级</th>
                                <th>填报情况</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="student : ${taskDetail.getRecords()}" th:id="'reportId-'+${student.getReportId()}">
                                <td th:text="${student.getSname()}">学生姓名</td>
                                <td th:text="${student.getSno()}">学生学号</td>
                                <td th:text="${student.getCollege()}">学院</td>
                                <td th:text="${student.getCname()}">班级</td>
                                <td><span th:text="${student.getReportId()!=null?'已填报':'未填报'}"
                                          th:class="${student.getReportId()!=null?'text-success':'text-danger'}">填报状态</span></td>
                                <td>
                                    <div class="btn-group">
                                        <a class="btn btn-xs btn-default" title="查看" data-toggle="tooltip"
                                           th:href="${student.getReportId()==null?'#':'/Report/Detail/'+student.getReportId()+'/'+student.getTaskId()}"><i class="mdi mdi-eye"></i>
                                        </a>
                                        <a class="btn btn-xs btn-default" title="退回" data-toggle="tooltip"
                                           th:href="'javascript:delReport(\''+${student.getReportId()}+'\')'"><i class="mdi mdi-window-close"></i>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <ul class="pagination">
                        <!-- 第一页按钮 -->
                        <li th:class="${taskDetail.hasPrevious()?'':'disabled'}" >
                            <a th:href="${taskDetail.hasPrevious()?('/Task/Detail/'+ taskId +'?p='+(taskDetail.getCurrent()-1)):'javascript:return false;'}">«</a>
                        </li>
                        <!-- 中间按钮 -->
                        <li th:each="i : ${#numbers.sequence(
                    (taskDetail.getCurrent()>3?taskDetail.getCurrent()-2:1)
                    , (taskDetail.getCurrent()<(taskDetail.getPages()-2)?taskDetail.getCurrent()+2:taskDetail.getPages())
                    )}"
                            th:class="${taskDetail.getCurrent()==i?'active':''}"
                        >
                            <a th:href="'/Task/Detail/'+ ${taskId} +'?p='+ ${i}"
                               th:text="${i}"
                            >???</a>
                        </li>
                        <!-- 最后一页按钮 -->
                        <li  th:class="${taskDetail.hasNext()?'':'disabled'}" >
                            <a th:href="${taskDetail.hasNext()?('/Task/Detail/'+ taskId +'?p='+(taskDetail.getCurrent()+1)):'javascript:return false;'}">»</a>
                        </li>
                        <li><span th:text="'共 '+ ${taskDetail.getCurrent()} +' / '+${taskDetail.getPages()}+' 条数据'">共 0 / 0 条数据</span></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <script>
        function delReport(reportId) {
            lightyear.loading('show');
            $.ajax({
                type: "POST",
                url: "/Report/Del",
                dataType: "json",
                data: {
                    "reportId": reportId,
                },
                success: function (data, status) {
                    console.log(data)
                    lightyear.loading('hide');
                    if (status === "success") {
                        if (data.code === 200){
                            lightyear.notify('您成功删除了一个模板~', 'success', 1000);
                            $("#reportId-" + reportId).remove();
                        } else{
                            console.log("后端拒绝")
                            lightyear.notify(data.msg, 'danger', 3000);
                        }
                    }else{
                        console.log("网络问题")
                        lightyear.notify('网络不可用，请稍候再试！！！', 'danger', 3000);
                    }
                },
                error: function (xhr, errorText, errorType) {
                    lightyear.loading('hide');
                    lightyear.notify('服务器错误，请稍后再试~', 'danger', 2000);
                }
            });
        }
    </script>
</div>
</html>
